package com.mcb.designmode;

import java.util.ArrayList;
import java.util.List;

public class ConcreteSubject implements Subject{

    //储存观察者用户，用于后续通知
    private List<Observer> observers = new ArrayList<>();

    @Override
    public void attach(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notity(String message) {
        for (Observer observer : observers) {
            observer.update(message);
        }
    }


}
